#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <string>

#include <QApplication>
#include <QTextCodec>

#include "reader.h"
#include "lexical.h"
#include "syntax.h"
#include "gType.h"
#include "serialize.h"
#include "transformation.h"

#include "qt/drawArea.h"
#include "qt/bakalarka.h"

#include "qt/codeText.h"
#include "qt/highlighter.h"

void printObject(gObject &object){

	gObject::iterator iter = object.begin();
	
	for(; iter != object.end(); iter++){
		switch((*iter)->getSymbol()){
			case lexical::token::GO_G:
				gTypeGo *g = dynamic_cast<gTypeGo *>(*iter);
				if(g->getTypeValue() == 0)
					std::cout << "G00 :";
				else if(g->getTypeValue() == 1)
					std::cout << "G01 :";
				else if(g->getTypeValue() == 2)
					std::cout << "G02 :";
				else if(g->getTypeValue() == 3)
					std::cout << "G03 :";
				std::cout << " x:" << (*g)[0];
				std::cout << " | y:" << (*g)[1];
				std::cout << " | z:" << (*g)[2];
				std::cout << std::endl;
				break;
		}		
	}

}

void printContainer(gObjectContainer &container){

	gObjectContainer::iterator iter = container.begin();
	
	for(; iter != container.end(); iter++){
		std::cout <<  "============= " << (*iter)->getName() << " =============" << std::endl;
		std::cout << "start: " << (*iter)->getStartOffset() << " length: " << (*iter)->getLength() << std::endl;
		printObject(**iter);
	}

}

int main(int argc, char *argv[]){
	
	Q_INIT_RESOURCE(resources);
	
	QApplication app(argc, argv);
	
	QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

	bakalarka mainWin;
	mainWin.show();
	return app.exec();
	
}
